home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / xceedzip / FRMUNZIP.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-04-26  |  13.6 KB  |  342 lines

  1. VERSION 5.00
  2. Begin VB.Form frmUnzip 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Unzip files"
  5.    ClientHeight    =   5730
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   6525
  9.    Icon            =   "frmUnzip.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   5730
  14.    ScaleWidth      =   6525
  15.    StartUpPosition =   1  'CenterOwner
  16.    Begin VB.TextBox txtFilesToProcess 
  17.       Height          =   810
  18.       Left            =   120
  19.       MultiLine       =   -1  'True
  20.       ScrollBars      =   2  'Vertical
  21.       TabIndex        =   2
  22.       Text            =   "frmUnzip.frx":030A
  23.       ToolTipText     =   "For multiple choices, seperate each filter with a line feed."
  24.       Top             =   1080
  25.       Width           =   4815
  26.    End
  27.    Begin VB.CommandButton cmdExtractDirectory 
  28.       Caption         =   "Browse"
  29.       Height          =   285
  30.       Left            =   4200
  31.       TabIndex        =   1
  32.       Top             =   360
  33.       Width           =   735
  34.    End
  35.    Begin VB.TextBox txtExtractDirectory 
  36.       Height          =   285
  37.       Left            =   120
  38.       TabIndex        =   0
  39.       Top             =   360
  40.       Width           =   3975
  41.    End
  42.    Begin VB.Frame fraDefaultPassword 
  43.       Caption         =   "Password protected files"
  44.       BeginProperty Font 
  45.          Name            =   "MS Sans Serif"
  46.          Size            =   8.25
  47.          Charset         =   0
  48.          Weight          =   700
  49.          Underline       =   0   'False
  50.          Italic          =   0   'False
  51.          Strikethrough   =   0   'False
  52.       EndProperty
  53.       Height          =   1150
  54.       Left            =   120
  55.       TabIndex        =   15
  56.       Top             =   4440
  57.       Width           =   3255
  58.       Begin VB.TextBox txtDefaultPassword 
  59.          Height          =   285
  60.          IMEMode         =   3  'DISABLE
  61.          Left            =   120
  62.          PasswordChar    =   "*"
  63.          TabIndex        =   9
  64.          Top             =   720
  65.          Width           =   3015
  66.       End
  67.       Begin VB.Label lblDefaultPassword 
  68.          Caption         =   "Try using the following password for unzipping files:"
  69.          Height          =   495
  70.          Left            =   120
  71.          TabIndex        =   16
  72.          Top             =   240
  73.          Width           =   3015
  74.       End
  75.    End
  76.    Begin VB.CommandButton cmdFilters 
  77.       Caption         =   "&Filters..."
  78.       Height          =   375
  79.       Left            =   5160
  80.       TabIndex        =   11
  81.       Top             =   600
  82.       Width           =   1215
  83.    End
  84.    Begin VB.Frame fraSkipping 
  85.       Caption         =   "Do not unzip files that..."
  86.       BeginProperty Font 
  87.          Name            =   "MS Sans Serif"
  88.          Size            =   8.25
  89.          Charset         =   0
  90.          Weight          =   700
  91.          Underline       =   0   'False
  92.          Italic          =   0   'False
  93.          Strikethrough   =   0   'False
  94.       EndProperty
  95.       Height          =   1335
  96.       Left            =   120
  97.       TabIndex        =   14
  98.       Top             =   3000
  99.       Width           =   4815
  100.       Begin VB.CheckBox chkSkipIfExisting 
  101.          Caption         =   "Already exist in the destination folder"
  102.          Height          =   195
  103.          Left            =   120
  104.          TabIndex        =   5
  105.          Top             =   240
  106.          Width           =   3735
  107.       End
  108.       Begin VB.CheckBox chkSkipIfNotExisting 
  109.          Caption         =   "Do not already exist in the destination folder"
  110.          Height          =   195
  111.          Left            =   120
  112.          TabIndex        =   6
  113.          Top             =   480
  114.          Width           =   3855
  115.       End
  116.       Begin VB.CheckBox chkSkipIfOlderDate 
  117.          Caption         =   "Are older than files already in the destination folder"
  118.          Height          =   195
  119.          Left            =   120
  120.          TabIndex        =   7
  121.          Top             =   720
  122.          Width           =   4575
  123.       End
  124.       Begin VB.CheckBox chkSkipIfOlderVersion 
  125.          Caption         =   "Are older versions of files already in the destination folder"
  126.          Height          =   195
  127.          Left            =   120
  128.          TabIndex        =   8
  129.          Top             =   960
  130.          Width           =   4455
  131.       End
  132.    End
  133.    Begin VB.Frame fraFolders 
  134.       Caption         =   "Folder options"
  135.       BeginProperty Font 
  136.          Name            =   "MS Sans Serif"
  137.          Size            =   8.25
  138.          Charset         =   0
  139.          Weight          =   700
  140.          Underline       =   0   'False
  141.          Italic          =   0   'False
  142.          Strikethrough   =   0   'False
  143.       EndProperty
  144.       Height          =   855
  145.       Left            =   120
  146.       TabIndex        =   13
  147.       Top             =   2040
  148.       Width           =   2775
  149.       Begin VB.CheckBox chkPreservePaths 
  150.          Caption         =   "Retrieve paths stored in zip file"
  151.          Height          =   195
  152.          Left            =   120
  153.          TabIndex        =   4
  154.          Top             =   480
  155.          Value           =   1  'Checked
  156.          Width           =   2535
  157.       End
  158.       Begin VB.CheckBox chkProcessSubFolders 
  159.          Caption         =   "Include subfolders"
  160.          Height          =   195
  161.          Left            =   120
  162.          TabIndex        =   3
  163.          Top             =   240
  164.          Value           =   1  'Checked
  165.          Width           =   1935
  166.       End
  167.    End
  168.    Begin VB.CommandButton cmdExtract 
  169.       Caption         =   "&Unzip!"
  170.       Height          =   375
  171.       Left            =   5160
  172.       TabIndex        =   10
  173.       Top             =   150
  174.       Width           =   1215
  175.    End
  176.    Begin VB.CommandButton cmdCancel 
  177.       Caption         =   "&Cancel"
  178.       Height          =   375
  179.       Left            =   5160
  180.       TabIndex        =   12
  181.       Top             =   1050
  182.       Width           =   1215
  183.    End
  184.    Begin VB.Label lblFilesToExtract 
  185.       Caption         =   "Specify which files in the zip file you want to unzip:"
  186.       Height          =   255
  187.       Left            =   120
  188.       TabIndex        =   18
  189.       Top             =   840
  190.       Width           =   4455
  191.    End
  192.    Begin VB.Label lblExtractDirectory 
  193.       Caption         =   "Select the folder where to unzip files to:"
  194.       Height          =   255
  195.       Left            =   120
  196.       TabIndex        =   17
  197.       Top             =   120
  198.       Width           =   3855
  199.    End
  200. Attribute VB_Name = "frmUnzip"
  201. Attribute VB_GlobalNameSpace = False
  202. Attribute VB_Creatable = False
  203. Attribute VB_PredeclaredId = True
  204. Attribute VB_Exposed = False
  205. Option Explicit
  206. '==================================================================
  207. ' Description: The frmUnzip form is shown when a user choses to unzip
  208. '              files from a zip file. It lets the user chose the
  209. '              unzipping folder, which files to unzip, and other
  210. '              unzipping settings and filter possibilities. If there
  211. '              are files selected in the main window, they will
  212. '              automatically be displayed in the frmUnzip window's
  213. '              list of files to unzip.
  214. '==================================================================
  215. Dim xCurrentZip As XceedZip
  216. '------------------------------------------------------------------------------------
  217. ' Calls data loading functions
  218. '------------------------------------------------------------------------------------
  219. Private Sub LoadExtractProperties(xZip As XceedZip, ListFiles As ListItems)
  220.     Call LoadFileProperties(xZip, ListFiles)
  221.     Call LoadFolderProperties(xZip)
  222.     Call LoadSkippingProperties(xZip)
  223.     ' Loads the default password
  224.     txtDefaultPassword.Text = xZip.EncryptionPassword
  225. End Sub
  226. '------------------------------------------------------------------------------------
  227. ' Loads xZip's File Properties to the corresponding
  228. ' object on the form. The function also reads the files selected by the user
  229. ' in the main window and loads them in the txtFilesToProcess textbox.
  230. '------------------------------------------------------------------------------------
  231. Private Sub LoadFileProperties(xZip As XceedZip, ListFiles As ListItems)
  232.     Dim sFilesToExtract     As String
  233.     txtExtractDirectory.Text = xZip.UnzipToFolder
  234.      
  235.     sFilesToExtract = GetSelectedFiles(ListFiles, True)
  236.     If sFilesToExtract = "" Then
  237.         txtFilesToProcess.Text = xZip.FilesToProcess
  238.     Else
  239.         txtFilesToProcess.Text = sFilesToExtract
  240.     End If
  241. End Sub
  242. '------------------------------------------------------------------------------------
  243. ' Initializes the "Include subfolders" and "Store paths in zip file"
  244. ' controls.
  245. '------------------------------------------------------------------------------------
  246. Private Sub LoadFolderProperties(xZip As XceedZip)
  247.     chkProcessSubFolders.Value = Checked
  248.     chkPreservePaths.Value = IIf(xZip.PreservePaths, vbChecked, vbUnchecked)
  249. End Sub
  250. '------------------------------------------------------------------------------------
  251. 'Loads the skipping properties.
  252. '------------------------------------------------------------------------------------
  253. Private Sub LoadSkippingProperties(xZip As XceedZip)
  254.     chkSkipIfExisting.Value = xZip.SkipIfExisting
  255.     chkSkipIfNotExisting.Value = xZip.SkipIfNotExisting
  256.     chkSkipIfOlderDate = xZip.SkipIfOlderDate
  257.     chkSkipIfOlderVersion = xZip.SkipIfOlderVersion
  258. End Sub
  259. '------------------------------------------------------------------------------------
  260. ' Shows the frmadd form to the user
  261. '------------------------------------------------------------------------------------
  262. Public Function ShowForm(xZip As XceedZip, ListFiles As ListItems) As Boolean
  263.     ' Sets the tag at "0" to later validate if the user clicked on Extract or Cancel
  264.     Tag = "0"
  265.     Height = 4770
  266.     Set xCurrentZip = xZip
  267.     ' Loads xZip's property values to the controls on the form
  268.     Call LoadExtractProperties(xZip, ListFiles)
  269.     ' Shows the window
  270.     frmUnzip.Show vbModal
  271.     ' If the tag's value is "1", then the user clicked on extract and the
  272.     ' values contained in the form are copied in the xZip object.
  273.     If frmUnzip.Tag = "1" Then
  274.         Call UpdateExtractParameters(xZip)
  275.     End If
  276.     ' The function returns true is the user has clicked on Extract.
  277.     ShowForm = (frmUnzip.Tag = "1")
  278. End Function
  279. '------------------------------------------------------------------------------------
  280. 'Calls functions that updates xZip's properties after the Extract button is pressed
  281. '------------------------------------------------------------------------------------
  282. Private Sub UpdateExtractParameters(xZip As XceedZip)
  283.     Call UpdateFileProperties(xZip)
  284.     Call UpdateFolderProperties(xZip)
  285.     Call UpdateSkippingProperties(xZip)
  286.     ' Updates the default password
  287.     xZip.EncryptionPassword = txtDefaultPassword.Text
  288. End Sub
  289. '------------------------------------------------------------------------------------
  290. ' Updates xZip's file properties
  291. '------------------------------------------------------------------------------------
  292. Private Sub UpdateFileProperties(xZip As XceedZip)
  293.     xZip.UnzipToFolder = txtExtractDirectory
  294.     xZip.FilesToProcess = txtFilesToProcess
  295. End Sub
  296. '------------------------------------------------------------------------------------
  297. ' Updates xZip's Folder properties
  298. '------------------------------------------------------------------------------------
  299. Private Sub UpdateFolderProperties(xZip As XceedZip)
  300.     xZip.ProcessSubfolders = chkProcessSubFolders.Value
  301.     xZip.PreservePaths = chkPreservePaths.Value
  302. End Sub
  303. '------------------------------------------------------------------------------------
  304. ' Updates xZip's skipping properties
  305. '------------------------------------------------------------------------------------
  306. Private Sub UpdateSkippingProperties(xZip As XceedZip)
  307.     xZip.SkipIfExisting = chkSkipIfExisting
  308.     xZip.SkipIfNotExisting = chkSkipIfNotExisting
  309.     xZip.SkipIfOlderDate = chkSkipIfOlderDate
  310.     xZip.SkipIfOlderVersion = chkSkipIfOlderVersion
  311. End Sub
  312. '------------------------------------------------------------------------------------
  313. ' If cancel is pressed, tag stays at "0"
  314. '------------------------------------------------------------------------------------
  315. Private Sub cmdCancel_Click()
  316.     Me.Hide
  317. End Sub
  318. '------------------------------------------------------------------------------------
  319. ' If Extract is clicked, tag takes the "1" value
  320. '------------------------------------------------------------------------------------
  321. Private Sub cmdExtract_Click()
  322.    Me.Tag = 1
  323.    Me.Hide
  324. End Sub
  325. '------------------------------------------------------------------------------------
  326. ' If the browse button is pressed, the default directories window
  327. ' loads up.
  328. '------------------------------------------------------------------------------------
  329. Private Sub cmdExtractDirectory_Click()
  330.     Dim PathName As String
  331.     If BrowseForFolder(PathName, "Please select the Extracting Directory") Then
  332.         txtExtractDirectory.Text = PathName
  333.     End If
  334. End Sub
  335. '------------------------------------------------------------------------------------
  336. ' If "Other Options" is clicked, the FrmExtractMoreOptions is loaded
  337. '------------------------------------------------------------------------------------
  338. Private Sub cmdFilters_Click()
  339.     Call frmFilters.ShowForm(xCurrentZip)
  340.     Call Unload(frmFilters)
  341. End Sub
  342.